﻿using System;
using System.Runtime.InteropServices;
using AI;
using Lua;
using UnityEngine;
using UnityEngine.Networking;

// Token: 0x020001C1 RID: 449
public class EntityBase : NetworkBehaviour
{
	// Token: 0x0600091F RID: 2335 RVA: 0x000554A8 File Offset: 0x000536A8
	public EntityBase()
	{
		this.id = EntityBase.entityIndex++;
	}

	// Token: 0x17000140 RID: 320
	// (get) Token: 0x06000920 RID: 2336 RVA: 0x0005551A File Offset: 0x0005371A
	public UnityEngine.Vector3 realPosition
	{
		get
		{
			return CenterOrigin.VirtualToWorld(this.virtualPosition);
		}
	}

	// Token: 0x17000141 RID: 321
	// (get) Token: 0x06000921 RID: 2337 RVA: 0x00055527 File Offset: 0x00053727
	// (set) Token: 0x06000922 RID: 2338 RVA: 0x0005552F File Offset: 0x0005372F
	public int id { get; set; }

	// Token: 0x17000142 RID: 322
	// (get) Token: 0x06000923 RID: 2339 RVA: 0x00055538 File Offset: 0x00053738
	public float Height
	{
		get
		{
			return this.myTransform.lossyScale.y * this.baseHeight;
		}
	}

	// Token: 0x17000143 RID: 323
	// (get) Token: 0x06000924 RID: 2340 RVA: 0x00055560 File Offset: 0x00053760
	public float HeightMesh
	{
		get
		{
			return this.myTransform.lossyScale.y * this.meshHeight;
		}
	}

	// Token: 0x17000144 RID: 324
	// (get) Token: 0x06000925 RID: 2341 RVA: 0x00055588 File Offset: 0x00053788
	// (set) Token: 0x06000926 RID: 2342 RVA: 0x000555BD File Offset: 0x000537BD
	public float AccurateScale
	{
		get
		{
			float num = this.myTransform.lossyScale.y;
			if (this.isGiantess)
			{
				num *= 1000f;
			}
			return num;
		}
		set
		{
			if (this.isGiantess)
			{
				value /= 1000f;
			}
			this.ChangeScale(value);
		}
	}

	// Token: 0x17000145 RID: 325
	// (get) Token: 0x06000927 RID: 2343 RVA: 0x000555DC File Offset: 0x000537DC
	public float Scale
	{
		get
		{
			return this.myTransform.lossyScale.y;
		}
	}

	// Token: 0x17000146 RID: 326
	// (get) Token: 0x06000929 RID: 2345 RVA: 0x00055605 File Offset: 0x00053805
	// (set) Token: 0x06000928 RID: 2344 RVA: 0x000555FC File Offset: 0x000537FC
	public MovementCharacter movement { get; protected set; }

	// Token: 0x0600092A RID: 2346 RVA: 0x0005560D File Offset: 0x0005380D
	public override void OnStartAuthority()
	{
		ObjectManager.Instance.OnObjectAuthoritySpawned(this);
	}

	// Token: 0x0600092B RID: 2347 RVA: 0x0005561A File Offset: 0x0005381A
	private void OnScaleChanged(float newScale)
	{
		this.NetworknetworkScale = newScale;
		if (!base.hasAuthority)
		{
			this._ChangeScale(newScale);
		}
	}

	// Token: 0x0600092C RID: 2348 RVA: 0x00055635 File Offset: 0x00053835
	private void OnVirtualPositionChanged(UnityEngine.Vector3 newPos)
	{
		if (!base.hasAuthority)
		{
			this.NetworkvirtualPosition = newPos;
		}
	}

	// Token: 0x0600092D RID: 2349 RVA: 0x0005564C File Offset: 0x0005384C
	protected virtual void Awake()
	{
		base.name = base.name.Replace("(Clone)", string.Empty);
		this.model = base.name;
		this.myTransform = base.transform;
		this.UpdateRealPosition(this.myTransform.position);
		this.hasNetworkTransform = (base.GetComponent<NetworkTransform>() != null);
		this.meshRenderers = this.GetRenderers();
		this.meshHeight = EntityBase.GetTallestRenderer(this.meshRenderers);
	}

	// Token: 0x0600092E RID: 2350 RVA: 0x000556CC File Offset: 0x000538CC
	public override void OnStartClient()
	{
		if (!this.isHumanoid)
		{
			this.RegisterEntity();
		}
	}

	// Token: 0x0600092F RID: 2351 RVA: 0x000556DF File Offset: 0x000538DF
	public virtual void RegisterEntity()
	{
		if (ObjectManager.Instance != null)
		{
			ObjectManager.Instance.OnObjectSpawned(this);
		}
		else
		{
			Debug.LogError("ObjectManager has not been instantiated yet.");
		}
	}

	// Token: 0x06000930 RID: 2352 RVA: 0x0005570B File Offset: 0x0005390B
	public Entity GetLuaEntity()
	{
		if (this._luaEntity == null)
		{
			this._luaEntity = new Entity(this);
		}
		return this._luaEntity;
	}

	// Token: 0x06000931 RID: 2353 RVA: 0x0005572A File Offset: 0x0005392A
	private void UpdateRealPosition(UnityEngine.Vector3 position)
	{
		this.NetworkvirtualPosition = CenterOrigin.WorldToVirtual(position);
	}

	// Token: 0x06000932 RID: 2354 RVA: 0x00055738 File Offset: 0x00053938
	public void SetActive(bool active)
	{
		base.gameObject.SetActive(active);
	}

	// Token: 0x06000933 RID: 2355 RVA: 0x00055748 File Offset: 0x00053948
	public virtual void Lock()
	{
		if (this.locked)
		{
			return;
		}
		this.locked = true;
		if (this.actionManager != null)
		{
			this.actionManager.ClearAll();
		}
		UnityEngine.Rigidbody component = base.GetComponent<UnityEngine.Rigidbody>();
		if (component == null)
		{
			return;
		}
		component.isKinematic = true;
		Gravity component2 = base.GetComponent<Gravity>();
		if (component2 == null)
		{
			return;
		}
		component2.enabled = false;
	}

	// Token: 0x06000934 RID: 2356 RVA: 0x000557BC File Offset: 0x000539BC
	public virtual void Unlock()
	{
		if (!this.locked)
		{
			return;
		}
		this.locked = false;
		UnityEngine.Rigidbody component = base.GetComponent<UnityEngine.Rigidbody>();
		if (component == null)
		{
			return;
		}
		component.isKinematic = false;
		Gravity component2 = base.GetComponent<Gravity>();
		if (component2 == null)
		{
			return;
		}
		component2.enabled = true;
	}

	// Token: 0x06000935 RID: 2357 RVA: 0x00055814 File Offset: 0x00053A14
	public virtual void Move(UnityEngine.Vector3 world_pos)
	{
		if (base.hasAuthority)
		{
			UnityEngine.Vector3 vector = world_pos.ToVirtual();
			this._Move(vector);
			this.CallCmdMove(vector);
		}
	}

	// Token: 0x06000936 RID: 2358 RVA: 0x00055841 File Offset: 0x00053A41
	[Command]
	private void CmdMove(UnityEngine.Vector3 newPosition)
	{
		if (this.hasNetworkTransform)
		{
			this.NetworkvirtualPosition = newPosition;
		}
		else
		{
			this.CallRpcMove(newPosition);
		}
	}

	// Token: 0x06000937 RID: 2359 RVA: 0x00055861 File Offset: 0x00053A61
	[ClientRpc]
	private void RpcMove(UnityEngine.Vector3 virtual_pos)
	{
		if (!base.hasAuthority)
		{
			this._Move(virtual_pos);
		}
	}

	// Token: 0x06000938 RID: 2360 RVA: 0x00055875 File Offset: 0x00053A75
	private void _Move(UnityEngine.Vector3 virtual_pos)
	{
		this.NetworkvirtualPosition = virtual_pos;
		this.myTransform.position = virtual_pos.ToWorld();
		this.myTransform.Translate(UnityEngine.Vector3.up * this.offset * this.Height);
	}

	// Token: 0x06000939 RID: 2361 RVA: 0x000558B5 File Offset: 0x00053AB5
	public virtual void ChangeScale(float newScale)
	{
		this._ChangeScale(newScale);
		if (base.hasAuthority || base.isServer)
		{
			this.CallCmdChangeScale(newScale);
		}
	}

	// Token: 0x0600093A RID: 2362 RVA: 0x000558DB File Offset: 0x00053ADB
	[Command]
	public void CmdChangeScale(float newScale)
	{
		this.NetworknetworkScale = newScale;
	}

	// Token: 0x0600093B RID: 2363 RVA: 0x000558E4 File Offset: 0x00053AE4
	[ClientRpc]
	private void RpcChangeScale(float newScale)
	{
		this._ChangeScale(newScale);
	}

	// Token: 0x0600093C RID: 2364 RVA: 0x000558F0 File Offset: 0x00053AF0
	public void _ChangeScale(float newScale)
	{
		if (this.virtualPosition == CenterOrigin.WorldToVirtual(UnityEngine.Vector3.zero) || base.gameObject.layer == Layers.playerLayer || base.gameObject.layer == Layers.microLayer)
		{
			this.UpdateRealPosition(this.myTransform.position);
		}
		if (newScale > this.maxSize)
		{
			newScale = this.maxSize;
		}
		if (newScale < this.minSize)
		{
			newScale = this.minSize;
		}
		UnityEngine.Transform parent = this.myTransform.parent;
		this.myTransform.SetParent(null);
		this.myTransform.localScale = UnityEngine.Vector3.one * newScale;
		this.myTransform.SetParent(parent);
		if (this.isGiantess)
		{
			this.Move(CenterOrigin.VirtualToWorld(this.virtualPosition));
		}
	}

	// Token: 0x0600093D RID: 2365 RVA: 0x000559D0 File Offset: 0x00053BD0
	public virtual void ChangeRotation(UnityEngine.Vector3 newRotation)
	{
		if (this.rotationEnabled && base.hasAuthority)
		{
			this._ChangeRotation(newRotation);
			this.CallCmdChangeRotation(newRotation);
		}
	}

	// Token: 0x0600093E RID: 2366 RVA: 0x000559F6 File Offset: 0x00053BF6
	[Command]
	private void CmdChangeRotation(UnityEngine.Vector3 newRotation)
	{
		if (!this.hasNetworkTransform)
		{
			this.CallRpcChangeRotation(newRotation);
		}
	}

	// Token: 0x0600093F RID: 2367 RVA: 0x00055A0A File Offset: 0x00053C0A
	[ClientRpc]
	private void RpcChangeRotation(UnityEngine.Vector3 newRotation)
	{
		if (!base.hasAuthority)
		{
			this._ChangeRotation(newRotation);
		}
	}

	// Token: 0x06000940 RID: 2368 RVA: 0x00055A1E File Offset: 0x00053C1E
	private void _ChangeRotation(UnityEngine.Vector3 newRotation)
	{
		this.myTransform.Rotate(newRotation);
	}

	// Token: 0x06000941 RID: 2369 RVA: 0x00055A2C File Offset: 0x00053C2C
	public virtual void ChangeOffset(float newOffset)
	{
		this._ChangeOffset(newOffset);
		if (base.hasAuthority)
		{
			this.CallRpcChangeOffset(newOffset);
		}
	}

	// Token: 0x06000942 RID: 2370 RVA: 0x00055A47 File Offset: 0x00053C47
	[Command]
	private void CmdChangeOffset(float newOffset)
	{
		this.CallRpcChangeOffset(newOffset);
	}

	// Token: 0x06000943 RID: 2371 RVA: 0x00055A50 File Offset: 0x00053C50
	[ClientRpc]
	private void RpcChangeOffset(float newOffset)
	{
		if (!base.hasAuthority)
		{
			this._ChangeOffset(newOffset);
		}
	}

	// Token: 0x06000944 RID: 2372 RVA: 0x00055A64 File Offset: 0x00053C64
	private void _ChangeOffset(float newOffset)
	{
		float d = newOffset - this.offset;
		this.myTransform.position += this.normal * d * this.Height;
		this.offset = newOffset;
	}

	// Token: 0x06000945 RID: 2373 RVA: 0x00055AB0 File Offset: 0x00053CB0
	public virtual void SetCollider(bool value)
	{
		if (this.colliderList == null)
		{
			this.FindColliders();
		}
		for (int i = 0; i < this.colliderList.Length; i++)
		{
			this.colliderList[i].enabled = value;
		}
	}

	// Token: 0x06000946 RID: 2374 RVA: 0x00055AF8 File Offset: 0x00053CF8
	protected virtual void FindColliders()
	{
		this.colliderList = base.GetComponentsInChildren<Collider>();
		foreach (Collider collider in this.colliderList)
		{
			float y = collider.bounds.size.y;
			if (y > this.baseHeight)
			{
				this.baseHeight = y;
			}
		}
	}

	// Token: 0x06000947 RID: 2375 RVA: 0x00055B5C File Offset: 0x00053D5C
	public virtual void DestroyObject(bool recursive = true)
	{
		if (base.hasAuthority || base.isServer)
		{
			this.CallCmdUnspawn(recursive);
		}
	}

	// Token: 0x06000948 RID: 2376 RVA: 0x00055B7B File Offset: 0x00053D7B
	public void ForceDestroy(bool recursive = true)
	{
		this._DestroyObject(recursive);
	}

	// Token: 0x06000949 RID: 2377 RVA: 0x00055B84 File Offset: 0x00053D84
	public void _DestroyObject(bool recursive)
	{
		if (recursive)
		{
			EntityBase[] componentsInChildren = base.GetComponentsInChildren<EntityBase>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].myTransform.SetParent(null);
			}
			for (int j = 0; j < componentsInChildren.Length; j++)
			{
				componentsInChildren[j].DestroyObject(false);
			}
		}
		UnityEngine.Object.Destroy(base.gameObject);
	}

	// Token: 0x0600094A RID: 2378 RVA: 0x00055BE9 File Offset: 0x00053DE9
	[Command]
	private void CmdUnspawn(bool recursive)
	{
		NetworkServer.UnSpawn(base.gameObject);
		this._DestroyObject(recursive);
	}

	// Token: 0x0600094B RID: 2379 RVA: 0x00055C00 File Offset: 0x00053E00
	public static float GetTallestRenderer(Renderer[] a)
	{
		float num = 0f;
		for (int i = 0; i < a.Length; i++)
		{
			if (a[i].bounds.size.y > num)
			{
				num = a[i].bounds.size.y;
			}
		}
		return num;
	}

	// Token: 0x0600094C RID: 2380 RVA: 0x00055C64 File Offset: 0x00053E64
	public void Render(bool enabled)
	{
		if (this.visible == enabled)
		{
			return;
		}
		this.visible = enabled;
		if (this.meshRenderers == null)
		{
			this.meshRenderers = this.GetRenderers();
		}
		for (int i = 0; i < this.meshRenderers.Length; i++)
		{
			this.meshRenderers[i].enabled = enabled;
		}
	}

	// Token: 0x0600094D RID: 2381 RVA: 0x00055CC3 File Offset: 0x00053EC3
	public bool IsVisible()
	{
		return this.visible;
	}

	// Token: 0x0600094E RID: 2382 RVA: 0x00003781 File Offset: 0x00001981
	public virtual bool IsTargettable()
	{
		return true;
	}

	// Token: 0x0600094F RID: 2383 RVA: 0x00055CCB File Offset: 0x00053ECB
	protected Renderer[] GetRenderers()
	{
		return base.GetComponentsInChildren<Renderer>();
	}

	// Token: 0x06000950 RID: 2384 RVA: 0x00055CD3 File Offset: 0x00053ED3
	public void Place()
	{
		if (base.isServer)
		{
			this.CallRpcPlace();
		}
	}

	// Token: 0x06000951 RID: 2385 RVA: 0x00055CE6 File Offset: 0x00053EE6
	[ClientRpc]
	public void RpcPlace()
	{
		this.OnPlaced();
	}

	// Token: 0x06000952 RID: 2386 RVA: 0x00002973 File Offset: 0x00000B73
	public virtual void OnPlaced()
	{
	}

	// Token: 0x06000953 RID: 2387 RVA: 0x00055CEE File Offset: 0x00053EEE
	public virtual UnityEngine.Vector3 GetEyesPosition()
	{
		return UnityEngine.Vector3.zero;
	}

	// Token: 0x06000954 RID: 2388 RVA: 0x00055CF8 File Offset: 0x00053EF8
	public float CheckForOverHeadObjects(float gtsHeight)
	{
		RaycastHit raycastHit;
		if (Physics.Raycast(base.transform.position + new UnityEngine.Vector3(0f, 1f, 0f) * base.transform.localScale.y, UnityEngine.Vector3.up, out raycastHit, gtsHeight * 2f, Layers.gtsWalkableMask))
		{
			return raycastHit.point.y;
		}
		return 0f;
	}

	// Token: 0x06000955 RID: 2389 RVA: 0x00055D78 File Offset: 0x00053F78
	static EntityBase()
	{
		NetworkBehaviour.RegisterCommandDelegate(typeof(EntityBase), EntityBase.kCmdCmdMove, new NetworkBehaviour.CmdDelegate(EntityBase.InvokeCmdCmdMove));
		EntityBase.kCmdCmdChangeScale = 117385254;
		NetworkBehaviour.RegisterCommandDelegate(typeof(EntityBase), EntityBase.kCmdCmdChangeScale, new NetworkBehaviour.CmdDelegate(EntityBase.InvokeCmdCmdChangeScale));
		EntityBase.kCmdCmdChangeRotation = 1772368674;
		NetworkBehaviour.RegisterCommandDelegate(typeof(EntityBase), EntityBase.kCmdCmdChangeRotation, new NetworkBehaviour.CmdDelegate(EntityBase.InvokeCmdCmdChangeRotation));
		EntityBase.kCmdCmdChangeOffset = -767614665;
		NetworkBehaviour.RegisterCommandDelegate(typeof(EntityBase), EntityBase.kCmdCmdChangeOffset, new NetworkBehaviour.CmdDelegate(EntityBase.InvokeCmdCmdChangeOffset));
		EntityBase.kCmdCmdUnspawn = 1554097966;
		NetworkBehaviour.RegisterCommandDelegate(typeof(EntityBase), EntityBase.kCmdCmdUnspawn, new NetworkBehaviour.CmdDelegate(EntityBase.InvokeCmdCmdUnspawn));
		EntityBase.kRpcRpcMove = -670770821;
		NetworkBehaviour.RegisterRpcDelegate(typeof(EntityBase), EntityBase.kRpcRpcMove, new NetworkBehaviour.CmdDelegate(EntityBase.InvokeRpcRpcMove));
		EntityBase.kRpcRpcChangeScale = -1681038704;
		NetworkBehaviour.RegisterRpcDelegate(typeof(EntityBase), EntityBase.kRpcRpcChangeScale, new NetworkBehaviour.CmdDelegate(EntityBase.InvokeRpcRpcChangeScale));
		EntityBase.kRpcRpcChangeRotation = 346286200;
		NetworkBehaviour.RegisterRpcDelegate(typeof(EntityBase), EntityBase.kRpcRpcChangeRotation, new NetworkBehaviour.CmdDelegate(EntityBase.InvokeRpcRpcChangeRotation));
		EntityBase.kRpcRpcChangeOffset = -684182515;
		NetworkBehaviour.RegisterRpcDelegate(typeof(EntityBase), EntityBase.kRpcRpcChangeOffset, new NetworkBehaviour.CmdDelegate(EntityBase.InvokeRpcRpcChangeOffset));
		EntityBase.kRpcRpcPlace = 683602077;
		NetworkBehaviour.RegisterRpcDelegate(typeof(EntityBase), EntityBase.kRpcRpcPlace, new NetworkBehaviour.CmdDelegate(EntityBase.InvokeRpcRpcPlace));
		NetworkCRC.RegisterBehaviour("EntityBase", 0);
	}

	// Token: 0x06000956 RID: 2390 RVA: 0x00002973 File Offset: 0x00000B73
	private void UNetVersion()
	{
	}

	// Token: 0x17000147 RID: 327
	// (get) Token: 0x06000957 RID: 2391 RVA: 0x00055F40 File Offset: 0x00054140
	// (set) Token: 0x06000958 RID: 2392 RVA: 0x00055F53 File Offset: 0x00054153
	public float NetworknetworkScale
	{
		get
		{
			return this.networkScale;
		}
		[param: In]
		set
		{
			uint dirtyBit = 1U;
			if (NetworkServer.localClientActive && !base.syncVarHookGuard)
			{
				base.syncVarHookGuard = true;
				this.OnScaleChanged(value);
				base.syncVarHookGuard = false;
			}
			base.SetSyncVar<float>(value, ref this.networkScale, dirtyBit);
		}
	}

	// Token: 0x17000148 RID: 328
	// (get) Token: 0x06000959 RID: 2393 RVA: 0x00055F94 File Offset: 0x00054194
	// (set) Token: 0x0600095A RID: 2394 RVA: 0x00055FA7 File Offset: 0x000541A7
	public UnityEngine.Vector3 NetworkvirtualPosition
	{
		get
		{
			return this.virtualPosition;
		}
		[param: In]
		set
		{
			uint dirtyBit = 2U;
			if (NetworkServer.localClientActive && !base.syncVarHookGuard)
			{
				base.syncVarHookGuard = true;
				this.OnVirtualPositionChanged(value);
				base.syncVarHookGuard = false;
			}
			base.SetSyncVar<UnityEngine.Vector3>(value, ref this.virtualPosition, dirtyBit);
		}
	}

	// Token: 0x0600095B RID: 2395 RVA: 0x00055FE6 File Offset: 0x000541E6
	protected static void InvokeCmdCmdMove(NetworkBehaviour obj, NetworkReader reader)
	{
		if (!NetworkServer.active)
		{
			Debug.LogError("Command CmdMove called on client.");
			return;
		}
		((EntityBase)obj).CmdMove(reader.ReadVector3());
	}

	// Token: 0x0600095C RID: 2396 RVA: 0x0005600F File Offset: 0x0005420F
	protected static void InvokeCmdCmdChangeScale(NetworkBehaviour obj, NetworkReader reader)
	{
		if (!NetworkServer.active)
		{
			Debug.LogError("Command CmdChangeScale called on client.");
			return;
		}
		((EntityBase)obj).CmdChangeScale(reader.ReadSingle());
	}

	// Token: 0x0600095D RID: 2397 RVA: 0x00056039 File Offset: 0x00054239
	protected static void InvokeCmdCmdChangeRotation(NetworkBehaviour obj, NetworkReader reader)
	{
		if (!NetworkServer.active)
		{
			Debug.LogError("Command CmdChangeRotation called on client.");
			return;
		}
		((EntityBase)obj).CmdChangeRotation(reader.ReadVector3());
	}

	// Token: 0x0600095E RID: 2398 RVA: 0x00056062 File Offset: 0x00054262
	protected static void InvokeCmdCmdChangeOffset(NetworkBehaviour obj, NetworkReader reader)
	{
		if (!NetworkServer.active)
		{
			Debug.LogError("Command CmdChangeOffset called on client.");
			return;
		}
		((EntityBase)obj).CmdChangeOffset(reader.ReadSingle());
	}

	// Token: 0x0600095F RID: 2399 RVA: 0x0005608C File Offset: 0x0005428C
	protected static void InvokeCmdCmdUnspawn(NetworkBehaviour obj, NetworkReader reader)
	{
		if (!NetworkServer.active)
		{
			Debug.LogError("Command CmdUnspawn called on client.");
			return;
		}
		((EntityBase)obj).CmdUnspawn(reader.ReadBoolean());
	}

	// Token: 0x06000960 RID: 2400 RVA: 0x000560B8 File Offset: 0x000542B8
	public void CallCmdMove(UnityEngine.Vector3 newPosition)
	{
		if (!NetworkClient.active)
		{
			Debug.LogError("Command function CmdMove called on server.");
			return;
		}
		if (base.isServer)
		{
			this.CmdMove(newPosition);
			return;
		}
		NetworkWriter networkWriter = new NetworkWriter();
		networkWriter.Write(0);
		networkWriter.Write((short)((ushort)5));
		networkWriter.WritePackedUInt32((uint)EntityBase.kCmdCmdMove);
		networkWriter.Write(base.GetComponent<NetworkIdentity>().netId);
		networkWriter.Write(newPosition);
		base.SendCommandInternal(networkWriter, 0, "CmdMove");
	}

	// Token: 0x06000961 RID: 2401 RVA: 0x00056144 File Offset: 0x00054344
	public void CallCmdChangeScale(float newScale)
	{
		if (!NetworkClient.active)
		{
			Debug.LogError("Command function CmdChangeScale called on server.");
			return;
		}
		if (base.isServer)
		{
			this.CmdChangeScale(newScale);
			return;
		}
		NetworkWriter networkWriter = new NetworkWriter();
		networkWriter.Write(0);
		networkWriter.Write((short)((ushort)5));
		networkWriter.WritePackedUInt32((uint)EntityBase.kCmdCmdChangeScale);
		networkWriter.Write(base.GetComponent<NetworkIdentity>().netId);
		networkWriter.Write(newScale);
		base.SendCommandInternal(networkWriter, 0, "CmdChangeScale");
	}

	// Token: 0x06000962 RID: 2402 RVA: 0x000561D0 File Offset: 0x000543D0
	public void CallCmdChangeRotation(UnityEngine.Vector3 newRotation)
	{
		if (!NetworkClient.active)
		{
			Debug.LogError("Command function CmdChangeRotation called on server.");
			return;
		}
		if (base.isServer)
		{
			this.CmdChangeRotation(newRotation);
			return;
		}
		NetworkWriter networkWriter = new NetworkWriter();
		networkWriter.Write(0);
		networkWriter.Write((short)((ushort)5));
		networkWriter.WritePackedUInt32((uint)EntityBase.kCmdCmdChangeRotation);
		networkWriter.Write(base.GetComponent<NetworkIdentity>().netId);
		networkWriter.Write(newRotation);
		base.SendCommandInternal(networkWriter, 0, "CmdChangeRotation");
	}

	// Token: 0x06000963 RID: 2403 RVA: 0x0005625C File Offset: 0x0005445C
	public void CallCmdChangeOffset(float newOffset)
	{
		if (!NetworkClient.active)
		{
			Debug.LogError("Command function CmdChangeOffset called on server.");
			return;
		}
		if (base.isServer)
		{
			this.CmdChangeOffset(newOffset);
			return;
		}
		NetworkWriter networkWriter = new NetworkWriter();
		networkWriter.Write(0);
		networkWriter.Write((short)((ushort)5));
		networkWriter.WritePackedUInt32((uint)EntityBase.kCmdCmdChangeOffset);
		networkWriter.Write(base.GetComponent<NetworkIdentity>().netId);
		networkWriter.Write(newOffset);
		base.SendCommandInternal(networkWriter, 0, "CmdChangeOffset");
	}

	// Token: 0x06000964 RID: 2404 RVA: 0x000562E8 File Offset: 0x000544E8
	public void CallCmdUnspawn(bool recursive)
	{
		if (!NetworkClient.active)
		{
			Debug.LogError("Command function CmdUnspawn called on server.");
			return;
		}
		if (base.isServer)
		{
			this.CmdUnspawn(recursive);
			return;
		}
		NetworkWriter networkWriter = new NetworkWriter();
		networkWriter.Write(0);
		networkWriter.Write((short)((ushort)5));
		networkWriter.WritePackedUInt32((uint)EntityBase.kCmdCmdUnspawn);
		networkWriter.Write(base.GetComponent<NetworkIdentity>().netId);
		networkWriter.Write(recursive);
		base.SendCommandInternal(networkWriter, 0, "CmdUnspawn");
	}

	// Token: 0x06000965 RID: 2405 RVA: 0x00056372 File Offset: 0x00054572
	protected static void InvokeRpcRpcMove(NetworkBehaviour obj, NetworkReader reader)
	{
		if (!NetworkClient.active)
		{
			Debug.LogError("RPC RpcMove called on server.");
			return;
		}
		((EntityBase)obj).RpcMove(reader.ReadVector3());
	}

	// Token: 0x06000966 RID: 2406 RVA: 0x0005639B File Offset: 0x0005459B
	protected static void InvokeRpcRpcChangeScale(NetworkBehaviour obj, NetworkReader reader)
	{
		if (!NetworkClient.active)
		{
			Debug.LogError("RPC RpcChangeScale called on server.");
			return;
		}
		((EntityBase)obj).RpcChangeScale(reader.ReadSingle());
	}

	// Token: 0x06000967 RID: 2407 RVA: 0x000563C5 File Offset: 0x000545C5
	protected static void InvokeRpcRpcChangeRotation(NetworkBehaviour obj, NetworkReader reader)
	{
		if (!NetworkClient.active)
		{
			Debug.LogError("RPC RpcChangeRotation called on server.");
			return;
		}
		((EntityBase)obj).RpcChangeRotation(reader.ReadVector3());
	}

	// Token: 0x06000968 RID: 2408 RVA: 0x000563EE File Offset: 0x000545EE
	protected static void InvokeRpcRpcChangeOffset(NetworkBehaviour obj, NetworkReader reader)
	{
		if (!NetworkClient.active)
		{
			Debug.LogError("RPC RpcChangeOffset called on server.");
			return;
		}
		((EntityBase)obj).RpcChangeOffset(reader.ReadSingle());
	}

	// Token: 0x06000969 RID: 2409 RVA: 0x00056418 File Offset: 0x00054618
	protected static void InvokeRpcRpcPlace(NetworkBehaviour obj, NetworkReader reader)
	{
		if (!NetworkClient.active)
		{
			Debug.LogError("RPC RpcPlace called on server.");
			return;
		}
		((EntityBase)obj).RpcPlace();
	}

	// Token: 0x0600096A RID: 2410 RVA: 0x0005643C File Offset: 0x0005463C
	public void CallRpcMove(UnityEngine.Vector3 virtual_pos)
	{
		if (!NetworkServer.active)
		{
			Debug.LogError("RPC Function RpcMove called on client.");
			return;
		}
		NetworkWriter networkWriter = new NetworkWriter();
		networkWriter.Write(0);
		networkWriter.Write((short)((ushort)2));
		networkWriter.WritePackedUInt32((uint)EntityBase.kRpcRpcMove);
		networkWriter.Write(base.GetComponent<NetworkIdentity>().netId);
		networkWriter.Write(virtual_pos);
		this.SendRPCInternal(networkWriter, 0, "RpcMove");
	}

	// Token: 0x0600096B RID: 2411 RVA: 0x000564B0 File Offset: 0x000546B0
	public void CallRpcChangeScale(float newScale)
	{
		if (!NetworkServer.active)
		{
			Debug.LogError("RPC Function RpcChangeScale called on client.");
			return;
		}
		NetworkWriter networkWriter = new NetworkWriter();
		networkWriter.Write(0);
		networkWriter.Write((short)((ushort)2));
		networkWriter.WritePackedUInt32((uint)EntityBase.kRpcRpcChangeScale);
		networkWriter.Write(base.GetComponent<NetworkIdentity>().netId);
		networkWriter.Write(newScale);
		this.SendRPCInternal(networkWriter, 0, "RpcChangeScale");
	}

	// Token: 0x0600096C RID: 2412 RVA: 0x00056524 File Offset: 0x00054724
	public void CallRpcChangeRotation(UnityEngine.Vector3 newRotation)
	{
		if (!NetworkServer.active)
		{
			Debug.LogError("RPC Function RpcChangeRotation called on client.");
			return;
		}
		NetworkWriter networkWriter = new NetworkWriter();
		networkWriter.Write(0);
		networkWriter.Write((short)((ushort)2));
		networkWriter.WritePackedUInt32((uint)EntityBase.kRpcRpcChangeRotation);
		networkWriter.Write(base.GetComponent<NetworkIdentity>().netId);
		networkWriter.Write(newRotation);
		this.SendRPCInternal(networkWriter, 0, "RpcChangeRotation");
	}

	// Token: 0x0600096D RID: 2413 RVA: 0x00056598 File Offset: 0x00054798
	public void CallRpcChangeOffset(float newOffset)
	{
		if (!NetworkServer.active)
		{
			Debug.LogError("RPC Function RpcChangeOffset called on client.");
			return;
		}
		NetworkWriter networkWriter = new NetworkWriter();
		networkWriter.Write(0);
		networkWriter.Write((short)((ushort)2));
		networkWriter.WritePackedUInt32((uint)EntityBase.kRpcRpcChangeOffset);
		networkWriter.Write(base.GetComponent<NetworkIdentity>().netId);
		networkWriter.Write(newOffset);
		this.SendRPCInternal(networkWriter, 0, "RpcChangeOffset");
	}

	// Token: 0x0600096E RID: 2414 RVA: 0x0005660C File Offset: 0x0005480C
	public void CallRpcPlace()
	{
		if (!NetworkServer.active)
		{
			Debug.LogError("RPC Function RpcPlace called on client.");
			return;
		}
		NetworkWriter networkWriter = new NetworkWriter();
		networkWriter.Write(0);
		networkWriter.Write((short)((ushort)2));
		networkWriter.WritePackedUInt32((uint)EntityBase.kRpcRpcPlace);
		networkWriter.Write(base.GetComponent<NetworkIdentity>().netId);
		this.SendRPCInternal(networkWriter, 0, "RpcPlace");
	}

	// Token: 0x0600096F RID: 2415 RVA: 0x00056678 File Offset: 0x00054878
	public override bool OnSerialize(NetworkWriter writer, bool forceAll)
	{
		if (forceAll)
		{
			writer.Write(this.networkScale);
			writer.Write(this.virtualPosition);
			return true;
		}
		bool flag = false;
		if ((base.syncVarDirtyBits & 1U) != 0U)
		{
			if (!flag)
			{
				writer.WritePackedUInt32(base.syncVarDirtyBits);
				flag = true;
			}
			writer.Write(this.networkScale);
		}
		if ((base.syncVarDirtyBits & 2U) != 0U)
		{
			if (!flag)
			{
				writer.WritePackedUInt32(base.syncVarDirtyBits);
				flag = true;
			}
			writer.Write(this.virtualPosition);
		}
		if (!flag)
		{
			writer.WritePackedUInt32(base.syncVarDirtyBits);
		}
		return flag;
	}

	// Token: 0x06000970 RID: 2416 RVA: 0x00056724 File Offset: 0x00054924
	public override void OnDeserialize(NetworkReader reader, bool initialState)
	{
		if (initialState)
		{
			this.networkScale = reader.ReadSingle();
			this.virtualPosition = reader.ReadVector3();
			return;
		}
		int num = (int)reader.ReadPackedUInt32();
		if ((num & 1) != 0)
		{
			this.OnScaleChanged(reader.ReadSingle());
		}
		if ((num & 2) != 0)
		{
			this.OnVirtualPositionChanged(reader.ReadVector3());
		}
	}

	// Token: 0x04000EE7 RID: 3815
	private static int entityIndex = 1;

	// Token: 0x04000EE8 RID: 3816
	[SyncVar(hook = "OnScaleChanged")]
	private float networkScale = 1f;

	// Token: 0x04000EE9 RID: 3817
	[SyncVar(hook = "OnVirtualPositionChanged")]
	public UnityEngine.Vector3 virtualPosition;

	// Token: 0x04000EEA RID: 3818
	public string model;

	// Token: 0x04000EEB RID: 3819
	public float offset;

	// Token: 0x04000EEC RID: 3820
	public float baseHeight = 1f;

	// Token: 0x04000EED RID: 3821
	public float meshHeight;

	// Token: 0x04000EEF RID: 3823
	private UnityEngine.Vector3 normal = UnityEngine.Vector3.up;

	// Token: 0x04000EF0 RID: 3824
	public bool isPositioned = true;

	// Token: 0x04000EF1 RID: 3825
	public bool isGiantess;

	// Token: 0x04000EF2 RID: 3826
	public bool isHumanoid;

	// Token: 0x04000EF3 RID: 3827
	public bool isMicro;

	// Token: 0x04000EF4 RID: 3828
	public bool isPlayer;

	// Token: 0x04000EF5 RID: 3829
	public float maxSize = 1000f;

	// Token: 0x04000EF6 RID: 3830
	public float minSize = 0.001f;

	// Token: 0x04000EF7 RID: 3831
	public bool rotationEnabled = true;

	// Token: 0x04000EF8 RID: 3832
	public GiantessIK ik;

	// Token: 0x04000EF9 RID: 3833
	public bool isDead;

	// Token: 0x04000EFA RID: 3834
	public UnityEngine.Rigidbody rbody;

	// Token: 0x04000EFB RID: 3835
	private bool visible = true;

	// Token: 0x04000EFC RID: 3836
	private Renderer[] meshRenderers;

	// Token: 0x04000EFD RID: 3837
	private Entity _luaEntity;

	// Token: 0x04000EFE RID: 3838
	public AnimationManager animationManager;

	// Token: 0x04000EFF RID: 3839
	public AIController ai;

	// Token: 0x04000F00 RID: 3840
	public ActionController actionManager;

	// Token: 0x04000F02 RID: 3842
	public SenseController senses;

	// Token: 0x04000F03 RID: 3843
	public UnityEngine.Transform myTransform;

	// Token: 0x04000F04 RID: 3844
	protected Collider[] colliderList;

	// Token: 0x04000F05 RID: 3845
	public bool locked;

	// Token: 0x04000F06 RID: 3846
	[SerializeField]
	private bool hasNetworkTransform;

	// Token: 0x04000F07 RID: 3847
	private static int kCmdCmdMove = -1216835419;

	// Token: 0x04000F08 RID: 3848
	private static int kRpcRpcMove;

	// Token: 0x04000F09 RID: 3849
	private static int kCmdCmdChangeScale;

	// Token: 0x04000F0A RID: 3850
	private static int kRpcRpcChangeScale;

	// Token: 0x04000F0B RID: 3851
	private static int kCmdCmdChangeRotation;

	// Token: 0x04000F0C RID: 3852
	private static int kRpcRpcChangeRotation;

	// Token: 0x04000F0D RID: 3853
	private static int kCmdCmdChangeOffset;

	// Token: 0x04000F0E RID: 3854
	private static int kRpcRpcChangeOffset;

	// Token: 0x04000F0F RID: 3855
	private static int kCmdCmdUnspawn;

	// Token: 0x04000F10 RID: 3856
	private static int kRpcRpcPlace;
}
